<?php  
  	
	include_once("config.php");	

	header("Content-type: text/html; charset=utf-8"); 

	// 设定要用的默认时区。自 PHP 5.1 可用   for strtotime
	date_default_timezone_set("Asia/Shanghai"); 

	$conn=@mysql_connect( $SQLhost , $SQLuser  , $SQLPWD ) or die ("数据库连接出错");  
   
 	@mysql_select_db( $DATABASE ,$conn) or die ("db链接失败".mysql_error());  
	
	mysql_query('SET NAMES UTF8')or die ("字符集设置错误");  
     	// SET NAMES gb2312
  
  
  // echo "get_magic_quotes_gpc".get_magic_quotes_gpc() ; // 判断magic_quotes_gpc是否打开   
 
function int($v){
	return intval($v);
}

function G( $n )
{ 
	$v=$_REQUEST [$n]; /// _POST
	//  echo $v;
	  return  $v;// mysql_real_escape_string($v);
}

function GetUID( $token )
{ 
     $strsql="select * from tb_user where token='$token'"; 

	// 执行sql查询
	$result=mysql_query($strsql, $conn);
	  
	 
	$rows=mysql_fetch_assoc($result);
	if(!$rows)
	{ 
		//echo "不存在此用户";
         if($result) mysql_free_result($result);
		return -1; 
	}
	if($result) mysql_free_result($result);
    return "";
}
 
 function getRecordCount( &$conn , &$sql   )
{  
    
	$retcount=0;
	// 执行sql查询
	$res=mysql_query($sql, $conn);
	  
	if($res)
	{ 
		while ($row = mysql_fetch_array($res ,MYSQL_ASSOC )) 
		{	 
			 $retcount++;	
		} 
		 mysql_free_result($res);
	}

   return $retcount; 
}

?>